import { App} from 'vue';
export const SEND_TEST_CMD_KEY = "send-test-cmd"; // 协商好的字符串Key
export const GET_TEST_DATA_KEY = "get-test-data"; // 配套的“获取数据”Key

export type Response<T = any> = {
  code: number;
  msg: string;
  data: T;
};

export type SendCmd<Payload = any, Return = Response> = (
  moduleName: string,
  cmd: string,
  payload?: Payload
) => Return | Promise<Return>;

export interface ModuleConfig {
  moudleType: string;
  name: string;
  version: string;
  description: string;
}

export interface ModuleInterface<
  EventData extends object = object,
  Payload = any,
  Return = Response
> {
  config: ModuleConfig;
  install(app: App): void;
  startup(): Promise<void>;
  updateEventData(data: Partial<EventData>): void;
  getEventData(): EventData;
  sendCommand(cmd: string, payload?: Payload): Return | Promise<Return>;
}